package com.sw.c.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;


@Configuration
@Slf4j
public class WebConfigurer implements WebMvcConfigurer {

    @Resource
    private FileMappings fileMappings;

    /**
     * 配置静态资源映射
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //配置文件路径映射
        registry.addResourceHandler("/" + fileMappings.getUploadPath() + "/**").addResourceLocations("file:"+fileMappings.getFilePath()+ "/");
    }

}